package de.nordakademie.hausarbeit.configwriter.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import de.nordakademie.hausarbeit.configwriter.services.StrutsConfDslGrammarAccess;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.Action;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.Method;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.PackageContainer;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.Parameter;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.Result;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.StrutsConfDslPackage;
import de.nordakademie.hausarbeit.configwriter.strutsConfDsl.StrutsConfig;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

@SuppressWarnings("all")
public class StrutsConfDslSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private StrutsConfDslGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == StrutsConfDslPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case StrutsConfDslPackage.ACTION:
				if(context == grammarAccess.getActionRule()) {
					sequence_Action(context, (Action) semanticObject); 
					return; 
				}
				else break;
			case StrutsConfDslPackage.CLASS:
				if(context == grammarAccess.getClassRule()) {
					sequence_Class(context, (de.nordakademie.hausarbeit.configwriter.strutsConfDsl.Class) semanticObject); 
					return; 
				}
				else break;
			case StrutsConfDslPackage.METHOD:
				if(context == grammarAccess.getMethodRule()) {
					sequence_Method(context, (Method) semanticObject); 
					return; 
				}
				else break;
			case StrutsConfDslPackage.PACKAGE_CONTAINER:
				if(context == grammarAccess.getPackageContainerRule()) {
					sequence_PackageContainer(context, (PackageContainer) semanticObject); 
					return; 
				}
				else break;
			case StrutsConfDslPackage.PARAMETER:
				if(context == grammarAccess.getParameterRule()) {
					sequence_Parameter(context, (Parameter) semanticObject); 
					return; 
				}
				else break;
			case StrutsConfDslPackage.RESULT:
				if(context == grammarAccess.getResultRule()) {
					sequence_Result(context, (Result) semanticObject); 
					return; 
				}
				else break;
			case StrutsConfDslPackage.STRUTS_CONFIG:
				if(context == grammarAccess.getStrutsConfigRule()) {
					sequence_StrutsConfig(context, (StrutsConfig) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (name=ID class=Class method=Method results+=Result*)
	 */
	protected void sequence_Action(EObject context, Action semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     name=QualifiedNameWithWildcard
	 */
	protected void sequence_Class(EObject context, de.nordakademie.hausarbeit.configwriter.strutsConfDsl.Class semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StrutsConfDslPackage.Literals.CLASS__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StrutsConfDslPackage.Literals.CLASS__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getClassAccess().getNameQualifiedNameWithWildcardParserRuleCall_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name=STRING
	 */
	protected void sequence_Method(EObject context, Method semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StrutsConfDslPackage.Literals.METHOD__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StrutsConfDslPackage.Literals.METHOD__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getMethodAccess().getNameSTRINGTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID extends=STRING actions+=Action*)
	 */
	protected void sequence_PackageContainer(EObject context, PackageContainer semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=STRING site=STRING)
	 */
	protected void sequence_Parameter(EObject context, Parameter semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StrutsConfDslPackage.Literals.PARAMETER__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StrutsConfDslPackage.Literals.PARAMETER__NAME));
			if(transientValues.isValueTransient(semanticObject, StrutsConfDslPackage.Literals.PARAMETER__SITE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StrutsConfDslPackage.Literals.PARAMETER__SITE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getParameterAccess().getNameSTRINGTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getParameterAccess().getSiteSTRINGTerminalRuleCall_3_0(), semanticObject.getSite());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     ((name='input' | name='success' | name='error')? (type='tiles' | type='chain') site=STRING? params+=Parameter*)
	 */
	protected void sequence_Result(EObject context, Result semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID package=PackageContainer)
	 */
	protected void sequence_StrutsConfig(EObject context, StrutsConfig semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StrutsConfDslPackage.Literals.STRUTS_CONFIG__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StrutsConfDslPackage.Literals.STRUTS_CONFIG__NAME));
			if(transientValues.isValueTransient(semanticObject, StrutsConfDslPackage.Literals.STRUTS_CONFIG__PACKAGE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StrutsConfDslPackage.Literals.STRUTS_CONFIG__PACKAGE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getStrutsConfigAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getStrutsConfigAccess().getPackagePackageContainerParserRuleCall_3_0(), semanticObject.getPackage());
		feeder.finish();
	}
}
